﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace KP_CommonLibrary.KP_CommonControls
{
    public partial class KPUCSaveItem : UserControl
    {
        public event EventHandler KPSaveAndNewClick, KPSaveAndCloseClick, KPCloseClick;

        public BaseItem GetItemBar(int index)
        {
            
            return tsSaveItem.Items[index];
        }
        public BaseItem GetItemBar(string itemName)
        {
            return tsSaveItem.Items[itemName];
        }
        public void AddItem(BaseItem item)
        {
            tsSaveItem.Items.Add(item);
        }
        public void AddItem(BaseItem item, int index)
        {
            tsSaveItem.Items.Add(item, index);
        }

        protected void OnSaveAndNewClick(object sender, EventArgs e)
        {
            if (KPSaveAndNewClick != null)
                KPSaveAndNewClick(sender, e);
        }
        protected void OnSaveAndCloseClick(object sender, EventArgs e)
        {
            if (KPSaveAndCloseClick != null)
                KPSaveAndCloseClick(sender, e);
        }
        protected void OnCloseClick(object sender, EventArgs e)
        {
            if (KPCloseClick != null)
                KPCloseClick(sender, e);
        }
        public KPUCSaveItem()
        {
            InitializeComponent();
            tsSaveItem.Font = KP_UIConfig.ControlFont;
        }
        void tsitem_MouseEnter(object sender, EventArgs e)
        {
            this.Cursor = Cursors.Hand;
        }
        void tsitem_MouseLeave(object sender, EventArgs e)
        {
            this.Cursor = Cursors.Default;
        }
        private void KPUCSaveItem_Load(object sender, EventArgs e)
        {
            
            foreach (BaseItem item in tsSaveItem.Items)
            {
                item.MouseEnter += new EventHandler(tsitem_MouseEnter);
                item.MouseLeave += new EventHandler(tsitem_MouseLeave);
            }
        }

       

        private void biSaveAndNew_Click(object sender, EventArgs e)
        {
            OnSaveAndNewClick(sender, e);
        }

        private void biSaveAndClose_Click(object sender, EventArgs e)
        {
            OnSaveAndCloseClick(sender, e);
        }

        private void biClose_Click(object sender, EventArgs e)
        {
            OnCloseClick(sender, e);
        }
    }
}
